package net.homelinux.chaoswg.io.renga.core.registries;

import java.util.HashMap;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;

import net.homelinux.chaoswg.io.renga.core.gui.operations.Operation;

public class OperationLoadRegistry {
    private static Map<Integer, Operation> _mapping;
    private static OperationLoadRegistry _this = null;
    
    private OperationLoadRegistry () {
        _mapping = new HashMap<Integer, Operation>();
    }
    
    public static final OperationLoadRegistry getOperationRegistry () {
        if (_this == null) {
            _this = new OperationLoadRegistry ();
        }
        
        return _this;
    }
    
    public void setOperationReader (final Integer id, final Operation o) {
        _mapping.put(id, o);
    }
    
    public Operation getOperationReader (final Integer id) {
        return _mapping.get(id);
    }
    
    public SortedSet<Integer> getKeys () {
        return new TreeSet<Integer>(_mapping.keySet());
    }
    
    public void clearRegistry () {
        _mapping.clear();
    }
}
